package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo5 {
    public static void main(String[] args) {
        try(Connection connection = DBUtil.getConnection()){
            Statement statement = connection.createStatement();
            String str = "SELECT username,password,age FROM userinfo";
            ResultSet resultSet = statement.executeQuery(str);
            while (resultSet.next()){
                String username = resultSet.getString("username");
                String password = resultSet.getString("password");
                int age = resultSet.getInt("age");
                System.out.println(username+"-"+password+"-"+age);
            }
        }catch(SQLException e){
            e.printStackTrace();
        }
    }

}
